package com.bjsxt.controller;

import com.bjsxt.Service.TbContentService;
import com.bjsxt.commons.pojo.BaizhanResult;
import com.bjsxt.pojo.TbContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author coder_z
 * @date 2023/3/8
 **/
@RestController
@RequestMapping("/backend/content")
public class TbContentController {
    @Autowired
    private TbContentService tbContentService;
    @PostMapping("/selectTbContentAllByCategoryId")
    public BaizhanResult showContent(long categoryId){
        return tbContentService.showContent(categoryId);
    }
    @PostMapping("/insertTbContent")
    public BaizhanResult insert(TbContent content){
        try {
            return tbContentService.insert(content);
        } catch (Exception e) {
            e.printStackTrace();
            return BaizhanResult.error(e.getMessage());
        }
    }
    @PostMapping("/deleteContentByIds")
    public BaizhanResult deleteById(long id){
        try {
            return tbContentService.deleteById(id);
        } catch (Exception e) {
            e.printStackTrace();
            return BaizhanResult.error(e.getMessage());
        }
    }
}
